<template>
  <div style="background-color:#efeff4;height: 100%">
    <!-- <scroller> -->
      <div style="padding-bottom:50px">
        <div class="bg">
          <!-- <photo-upload title="" :pageToken="pageToken" :fieldToken="fieldToken" 
            v-model="photo" :readonly="true" class="photo">
          </photo-upload>-->
          <div class="userFullName">{{userFullName}}</div>
          <div class="userDept">{{userDept}}</div>
        </div>
        <group>
          <cell title="手机" v-model="phone">
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/moblie.png"
            />
          </cell>
          <!-- <cell title="电话" v-model="phone">
            <img slot="icon" width="20" style="display:block;margin-right:5px;" src="../assets/img/tel.png"/>
          </cell>-->
          <cell title="邮箱" v-model="email">
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/email.png"
            />
          </cell>
          <cell title="下载二维码" @click.native="toQrCode">
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/code.png"
            />
            <slot>
             <img
              style="width:20px;height: 20px"
              src="@/assets/img/arrowhead.png"/>
            </slot>
          </cell>
          <cell title="版本信息" value="3.6.2"> 
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/version.png"
            />
          </cell>
           <!-- <cell title="安全教育早会" link="/safetyMeetingList" is-link >
            <img slot="icon" width="20" style="display:block;margin-right:5px;" src="../assets/img/shigongUnit.png"/>
          </cell> -->
        </group>

        <!-- <group>
          <cell link="/userBack" title="用户反馈" is-link>
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/userback.png"
            />
          </cell>
          <cell title="版本信息" value="2.1.11"> 
            <img
              slot="icon"
              width="20"
              style="display:block;margin-right:5px;"
              src="../assets/img/version.png"
            />
          </cell>
          <cell title="角色权限"  is-link>
            <img slot="icon" width="20" style="display:block;margin-right:5px;" src="../assets/img/version.png"/>
          </cell>
        </group> -->

        <div class="logout_div" @click="logout">
          <button class="logout">退出登录</button>
        </div>
      </div>
    <!-- </scroller> -->
  </div>
</template>

<script>
import { Cell, Group } from "vux";
export default {
  name: "my",
  components: {
    Cell,
    Group
  },
  mounted() {
    this.getUserInfo();
    this.pageToken = this.guid();
    this.fieldToken = this.guid();
    // this.getUpdateLog();//版本信息
  },
  data() {
    var user = this.$store.state.user;
    return {
      //   userFullName: user.ADUSER_NAME,
      //   userJob: user.Forth_DeptName,
      //   userCompany: user.Third_DeptName,
      //   userDept: user.Default_DeptName,
      //   userMobil: user.mobil,
      //   userTel: user.tel,
      //   userEmail: user.EMAIL ? user.EMAIL : "无",
      //   userRoleNames : user.RoleNames,
      userInfoList: [],
      pageToken: "",
      fieldToken: "",
      photo: "",
      pageIndex: 1,
      pageSize: 50,
      userFullName: "",
      userDept: "",
      phone: "",
      tel: "",
      email: "",
      updateLog: ""
    };
  },
  methods: {
    getUpdateLog() {
      let params = {
        FixJSON: {
          _method: "UPDATE_LOG.selectLastOne"
        }
      };

      this.$ajax({
        url: this.COMMON_URL,
        methods: "post",
        params: params,
        async: false
      }).then(res => {
        this.updateLog = res.data.res;
      });
    },
    logout: function() {
      const _this = this;
      this.$vux.confirm.show({
        content: "确认退出？",
        position: "middle",
        onConfirm() {
          // localStorage.clear();
          _this.$store.commit("setSystemCount", 0);
          _this.$store.commit("setTaskListCount", 0);
          _this.$store.commit("setBadge", 0);
          _this.$store.commit("setTimes", 0);
          _this.$store.commit("setProjectFlag", false);
          _this.$store.commit("setDangerFlag", false);
          _this.$store.commit("setQualityFlag", false);
          _this.$store.commit("setDailyCheckFlag", false);
          _this.$store.commit("setColnum", 3);
          _this.$store.commit("setConstructionInfoFlag", false);
          _this.$router.push("/");
        }
      });
    },
    //获取当前登录用户信息
    getUserInfo() {
      this.userInfoList = [];
      var params =
        '{"_method":"formService.getFormData","requestEventData":{"eventType":"formInitEvent","formType":1,"bizObjId":"PER_BASE_NEW_SELF","formId":"UserInfo"},"useType":"view","getData":{"useType":"view","objName":"PER_BASE_NEW_SELF","relatedObj":["PER_BASE_NEW_SELF","PER_BASE_NEW"],"pk":[]},"getSysVar":{"inputname":"{sysLoginUser.loginId}","GUID":"{sysIndex.GUID}","GROUPPATHID":"{sysLoginUser.orgId}","FIRST_DEPTNAME":"{sysLoginUser.projectName}"},"getFormVerify":{"objName":"PER_BASE_NEW_SELF","viewId":"UserInfo"},"getToolbar":{"useType":"view","objName":"PER_BASE_NEW_SELF","viewId":"UserInfo"}}';
      this.$ajax({
        url:
          this.COMMON_URL,
        method: "post",
        // data: this.signMD5({FixJSON: params})
        data: {FixJSON: params}
      }).then(res => {
        console.log(res);
        this.userInfoList = res.data.getData.PER_BASE_NEW_SELF[0];
        //this.userInfoList = [res.data.getData.PER_BASE_NEW[0]]
        this.photo = this.userInfoList.PHOTO.val;
        this.userFullName = this.userInfoList.USER_FULLNAME.val;
        this.userDept = this.userInfoList.GROUPPATHNAME.val;
        this.phone = this.userInfoList.TELEPHONE_CODE.val;
        this.email = this.userInfoList.EMAIL.val;
        console.log(this.userInfoList);
      });
    },
    toQrCode() {
      this.$router.push({
        path: "qrcode",
        name: "qrcode",
        query: {
          item: this.userInfoList
        }
      });
    }
    // userBack(){
    //   console.log('111111111111')
    //   var params ='{"_method":"component.getListData","_param":{"bizObj":"PMBASE_USERBACK2","service":"selectMore","fields":"*","filter":"1=1","currentPageIndex":'+ this.pageIndex +',"pageSize":'+ this.pageSize +',"orderList":[{"field":"INPUTDATE","order":"desc"}],"QueryFormData":""}}';

    //   this.$ajax({
    //     url : this.COMMON_URL + '_objName=PMBASE_USERBACK2&_viewId=PMBASE_USERBACK2_list',
    //     method : 'post',
    //     data : {
    //       FixJSON : params
    //     }
    //   }).then(res =>{
    //     console.log(res)
    //   })
    // }
  }
};
</script>

<style scoped>
.bg {
  width: 100%;
  height: 130px;
  background: url("../assets/img/my_bg.png");
}
.logout_div{
  text-align:center;
  padding:10px;
  position: absolute;
  width: 95%;
  top: 80%;
}
.logout {
  width: 95%;
  height: 50px;
  background: #4D86FF;
  border-radius: 4px;
  color: #ffffff;
  font-size: 16px;
  border: 0;
  font-family: PingFangSC-Regular;
}
.userFullName {
  color: #ffffff;
  font-size: 18px;
  font-family: PingFangSC-Semibold;
  font-weight: 600;
  text-align: left;
  margin-left: 5%;
  padding-top: 55px;
}
.userRoleNames {
  font-size: 14px;
  font-family: PingFangSC-Regular;
  font-weight: 400;
  color: #b3b5ba;
  line-height: 20px;
  text-align: center;
  opacity: 0.5;
  margin-top: 3%;
}
.userDept {
  font-size: 12px;
  font-family: PingFangSC-Regular;
  font-weight: 400;
  color: #ffffff;
  line-height: 20px;
  opacity: 0.5;
  text-align: left;
  margin-top: 3%;
  padding-bottom: 5%;
  margin-left: 5%;
}
.photo {
  margin-left: 40%;
  padding-top: 15%;
}
.photo img {
  width: 40px;
  height: 40px;
}
.content /deep/ .weui-cells:before {
  border-top: none;
}
.content /deep/ .weui-cells .weui-cell {
  padding: 10px 15px;
}
/* .content /deep/ .weui-cells {
  margin-top: 10px !important;
} */
.weui-cell:before{
  width: 95%;
  left: 5% !important;
  color: #eeeeee;
}
</style>
